#include <vector>
using namespace std;
/*
 * @lc app=leetcode.cn id=119 lang=cpp
 *
 * [119] 杨辉三角 II
 */

// @lc code=start
class Solution {
public:

    // C(n, i)
    vector<int> getRow(int rowIndex) {
        vector<int> res = {1};
        for (int k = 1; k <= rowIndex; k++) {
            if (rowIndex - k < k) res.push_back(res[rowIndex - k]);
            else {
                int t = 1LL * res.back() * (rowIndex - k + 1) / k;
                res.push_back(t);
            }
        }
        return res;
    }

};
// @lc code=end

